package com.foo.midterm;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends AppCompatActivity {

    public static final String EXTRA_INF = "com.midterm.INF";


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button regButton = findViewById(R.id.reg_button);
        regButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                login(view);
            }
        });

    }

    public void login(View v) {
        Intent intent = new Intent(this, DisplayMessageActivity.class);
        //获取文本框信息
        //学生姓名
        EditText personNameText = findViewById(R.id.editPersonName);
        //学生密码
        EditText passwordText = findViewById(R.id.editPassword);
        //学生学号
        EditText studentIDText = findViewById(R.id.editStudentID);

        String personName = personNameText.getText().toString();
        String password = passwordText.getText().toString();
        String studentID = studentIDText.getText().toString();
        //将获得的信息附加到意图中
        String[] inf = new String[]{studentID, personName, password};
        intent.putExtra(this.EXTRA_INF, inf);
        System.out.println(inf);
        //执行意图
        startActivity(intent);
    }
}